/*****************************************************************************
*
*  PROJECT:     SlipStream
*               (Text classes)
*  LICENSE:     GNU General Public License v3 - http://www.gnu.org/licenses/gpl.html

*  DEVELOPERS:  Philip Farquharson <B00137077@studentmail.uws.ac.uk>
*				John Gray <B00145524@studentmail.uws.ac.uk>		
*				Zohaib Bhatti <B00104280@studentmail.uws.ac.uk>
*				Euan Hislop <B00138636@studentmail.uws.ac.uk>
*
*****************************************************************************/
#include "CTextManager.h"

template<> CTextManager * CSingleton< CTextManager >::m_pSingleton = NULL;

CTextManager::CTextManager( void ) { }

CTextManager::~CTextManager ( void )
{
	std::list<CTextObject*>::const_iterator iter = m_textObjects.begin();
	for ( ; iter != m_textObjects.end (); ++iter )
	{
		CTextObject* pTextObject = static_cast < CTextObject* > ( *iter );

		assert ( pTextObject );

		// free our resources
		delete pTextObject;
	}
}

CTextObject* CTextManager::createTextObject ( CVector2 vecPosition, CColor colText, const char* szInitialText )
{
	CTextObject* pTextObject = new CTextObject ( vecPosition, colText, szInitialText);
	m_textObjects.push_back ( pTextObject );
	return pTextObject;
}

void CTextManager::Draw ()
{
	std::list<CTextObject*>::const_iterator iter = m_textObjects.begin();
	for ( ; iter != m_textObjects.end (); ++iter )
	{
		CTextObject* pTextObject = static_cast < CTextObject* > ( *iter );

		assert ( pTextObject );

		pTextObject->Draw(m_uiFontBase);
	}
}